﻿// Copyright (c) 2012 - 2020 Jared Zheng <jaredz at outlook dot com>
// Buddha Framework is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Create : 2012-12-01 version 0.1 Jared Zheng <jaredz at outlook dot com>
// Update : 2018-12-05 version 3.1.5 Jared Zheng <jaredz at outlook dot com>

#include "stdafx.h"
#include "CommonServer.hxx"
#include "AuthorServerImp.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// CCommonServerSystem : CSubSystem
INLINE Int CCommonServerSystem::GetComponentInfo(MAP_COMPONENT_INFO& Components)
{
    Components.Add(UUID_OF(IAuthorServer), CStringKey(COM_OF( IAuthorServer )));
    return Components.GetSize();
}

INLINE bool CCommonServerSystem::FindComponent(const CUUID& uuId)
{
    if (uuId == UUID_OF( IAuthorServer ))
    {
        return true;
    }
    return false;
}

INLINE bool CCommonServerSystem::CreateComponent(const CUUID& uuId, CComponentPtr& CComponentPtrRef)
{
    CComponentPtrRef = nullptr;
    if (uuId == UUID_OF( IAuthorServer ))
    {
        CAuthorServer* pServer = MNEW CAuthorServer;
        if (pServer != nullptr)
        {
            CComponentPtrRef = static_cast<ICommonServer*>(pServer);
            return true;
        }
    }
    return false;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// CreateSubSystem
CCommonServerSystem   GServerSystem;

C_EXPORT CSubSystem* CreateSubSystem(const CUUID& uuId)
{
    if (uuId == UUID_OF( CCommonServerSystem ))
    {
        return (&GServerSystem);
    }
    return nullptr;
}


